package com.hishop.coupon.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hishop.common.utils.PageUtils;
import com.hishop.coupon.dao.CouponDao;
import com.hishop.coupon.entity.CouponEntity;
import com.hishop.coupon.service.CouponService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


@Service("couponService")
public class CouponServiceImpl extends ServiceImpl<CouponDao, CouponEntity> implements CouponService {

    @Resource
    private CouponDao couponDao;

    @Override
    public PageUtils queryPage(String key, Page<CouponEntity> page) {
        QueryWrapper<CouponEntity> qw = new QueryWrapper<>();
        if (!key.equals("")) {
            qw.like("id", key)
                    .or().like("coupon_type",key)
                    .or().like("coupon_name",key)
                    .or().like("note",key)
            ;
        }
        return new PageUtils(couponDao.selectPage(page,qw));
    }

}